import request from '@/utils/request'
// 获取商品分类数据列表
export function getCateListApi (query) {
  return request({
    url: '/api/categories',
    method: 'get',
    params: query
  })
}

// 添加商品分类
export function postCateApi (data) {
  return request({
    url: '/api/categories/',
    method: 'post',
    data
  })
}

// 根据Id查询商品分类信息
export function getCateByIdApi (query) {
  return request({
    url: '/api/categories/' + query,
    method: 'get'
  })
}

// 编辑商品分类信息
export function putCateByIdApi (query, data) {
  return request({
    url: '/api/categories/' + query.id,
    method: 'put',
    params: query,
    data
  })
}

// 删除商品分类
export function deleteCateApi (query) {
  return request({
    url: '/api/categories/' + query.cat_id,
    method: 'delete'
  })
}

// 获取参数列表
export function getAttributesByCateId (query) {
  return request({
    url: '/api/categories/' + query.id + '/attributes',
    method: 'get',
    params: query
  })
}

// 添加参数
export function postAttributesByCateId (query, data) {
  return request({
    url: '/api/categories/' + query.id + '/attributes',
    method: 'post',
    data
  })
}

// 显示要编辑参数的信息
export function getAttributesByAttrId (query, data) {
  return request({
    url: '/api/categories/' + query.id + '/attributes/' + query.attrId,
    method: 'get',
    params: query,
    data
  })
}

// 编辑参数
export function putAttributesByAttrId (query, data) {
  return request({
    url: '/api/categories/' + query.id + '/attributes/' + query.attrId,
    method: 'put',
    params: query,
    data
  })
}

// 删除参数
export function deleteAttributesByAttrId (query) {
  return request({
    url: '/api/categories/' + query.id + '/attributes/' + query.attrId,
    method: 'delete'
  })
}
